<template>
  <a-card :bordered="false">
    <standard-table
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      @change="onChange"
      @selectedRowChange="onSelectChange"
    >
      <div slot="description" slot-scope="{ text }">
        {{ text }}
      </div>
      <div slot="action" slot-scope="{ text, record }">
        <a style="margin-right: 8px"> <a-icon type="plus" />新增 </a>
        <a style="margin-right: 8px"> <a-icon type="edit" />编辑 </a>
        <a @click="deleteRecord(record.key)"> <a-icon type="delete" />删除 </a>
      </div>
      <template slot="statusTitle">
        <a-icon @click.native="onStatusTitleClick" type="info-circle" />
      </template>
    </standard-table>
  </a-card>
</template>

<script>
import StandardTable from "@/components/table/StandardTable";
import { getAll } from "@/services/abp";

const columns = [
  {
    title: "编号",
    dataIndex: "id",
  },
  {
    title: "用户名",
    dataIndex: "name",
  },
  {
    title: "创建时间",
    dataIndex: "creationTime",
    sorter: true,
    customRender: (text) => text + " h",
  },
  {
    title: "操作",
    scopedSlots: { customRender: "action" },
  },
];
export default {
  name: "AdminPage",
  i18n: require("./i18n"),
  components: { StandardTable },
  data() {
    return {
      dataSource: [],
      columns: columns,
    };
  },
  methods: {
    getData() {},
    onSelectChange() {},
    onChange() {},
    deleteRecord(key) {
      this.dataSource = this.dataSource.filter(item => item.key !== key)
    },
    fetchData() {
      getAll(
        {
          SkipCount: 0,
          MaxResultCount: 10,
        },
        "User"
      ).then((res)=>{
        this.dataSource = res.data.result.items
      });
    },
  },
  mounted() {
    this.fetchData();
  },
};
</script>

<style scoped>
</style>
